package p270jp.pxv.android.activity;

import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.activity.ComponentActivity;
import androidx.compose.p026ui.platform.C0536v1;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelStore;
import com.google.android.material.appbar.MaterialToolbar;
import p014ae.AbstractActivityC0165u1;
import p018ai.PixivSettings;
import p022am.NovelBackupService;
import p047bg.C1124a;
import p064c6.Preconditions;
import p081cn.progressionUtil;
import p134ei.AnalyticsAction;
import p134ei.PixivAnalytics;
import p162fl.WorkTypeRepository;
import p165fo.Subscribe;
import p189gn.AbstractC3435a;
import p216hn.Lambda;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.commonObjects.model.WorkType;
import p270jp.pxv.android.event.DiscardBackupFromMyWork;
import p270jp.pxv.android.event.RestoreNovelBackupFromMyWork;
import p270jp.pxv.android.event.ShowUploadIllustEvent;
import p270jp.pxv.android.event.ShowUploadNovelEvent;
import p270jp.pxv.android.upload.IllustUploadActivity;
import p270jp.pxv.android.uploadNovel.presentation.activity.NovelUploadActivity;
import p294ko.ViewModelOwner;
import p310lc.C4621b;
import p314lg.ActivityMyWorkBinding;
import p325m0.MutabilityOwnership;
import p347mm.AccountUtils;
import p347mm.MailAuthorizationListener;
import p350mp.Timber;
import p436q6.StringMerger;
import p447qi.EventPublishDialogFragment;
import p549uj.EditNovelDraftEvent;
import p575vj.MyWorkAction;
import p575vj.MyWorkActionCreator;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;
import p665z6.C7461p;
import p671zc.CompositeDisposable;
import p680zl.NovelPostParameter;

/* compiled from: MyWorkActivity.kt */
/* renamed from: jp.pxv.android.activity.MyWorkActivity */
/* loaded from: classes2.dex */
public final class MyWorkActivity extends AbstractActivityC0165u1 {

    /* renamed from: h0 */
    public static final /* synthetic */ int f18407h0;

    /* renamed from: b0 */
    public final AbstractC6949c f18408b0 = C4621b.m3851a(this, C4018a.f18414c);

    /* renamed from: c0 */
    public final AbstractC6949c f18409c0 = Preconditions.m9802P(3, new C4025h(this, null, null, new C4024g(this), null));

    /* renamed from: d0 */
    public final CompositeDisposable f18410d0 = new CompositeDisposable();

    /* renamed from: e0 */
    public final AbstractC6949c f18411e0 = Preconditions.m9802P(1, new C4021d(this, null, null));

    /* renamed from: f0 */
    public final AbstractC6949c f18412f0 = Preconditions.m9802P(1, new C4022e(this, null, null));

    /* renamed from: g0 */
    public final AbstractC6949c f18413g0 = Preconditions.m9802P(1, new C4023f(this, null, null));

    /* compiled from: MyWorkActivity.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$b */
    /* loaded from: classes2.dex */
    public static final class C4019b implements MailAuthorizationListener {

        /* renamed from: b */
        public final /* synthetic */ ShowUploadIllustEvent f18416b;

        public C4019b(ShowUploadIllustEvent showUploadIllustEvent) {
            MyWorkActivity.this = r1;
            this.f18416b = showUploadIllustEvent;
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: a */
        public void mo949a() {
            MyWorkActivity myWorkActivity = MyWorkActivity.this;
            int i = MyWorkActivity.f18407h0;
            AccountUtils.m3549e(myWorkActivity, myWorkActivity.getString(R.string.profile_registration_required_popup_upload_title));
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: b */
        public void mo948b() {
            MyWorkActivity myWorkActivity = MyWorkActivity.this;
            int i = MyWorkActivity.f18407h0;
            String string = myWorkActivity.getString(R.string.mail_authorization_submit_illustration);
            MutabilityOwnership.m3746l(string, "getString(jp.pxv.android…tion_submit_illustration)");
            AccountUtils.m3551c(myWorkActivity.m11131K0(), string);
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: c */
        public void mo947c() {
            PixivAnalytics eVar = MyWorkActivity.this.f18757A;
            MutabilityOwnership.m3746l(eVar, "pixivAnalytics");
            eVar.m6527c(3, AnalyticsAction.UPLOAD_SHOW_VIA_MY_WORK_LIST, null);
            MyWorkActivity myWorkActivity = MyWorkActivity.this;
            IllustUploadActivity.C4331a aVar = IllustUploadActivity.f19355K;
            WorkType workType = this.f18416b.getWorkType();
            MutabilityOwnership.m3746l(workType, "event.workType");
            myWorkActivity.startActivity(aVar.m4539a(myWorkActivity, workType, null));
        }

        @Override // p347mm.MailAuthorizationListener
        public void failure(Throwable th) {
            MutabilityOwnership.m3745m(th, "e");
            Timber.f23100a.mo3527b(th);
        }
    }

    /* compiled from: MyWorkActivity.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$c */
    /* loaded from: classes2.dex */
    public static final class C4020c implements MailAuthorizationListener {
        public C4020c() {
            MyWorkActivity.this = r1;
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: a */
        public void mo949a() {
            MyWorkActivity myWorkActivity = MyWorkActivity.this;
            int i = MyWorkActivity.f18407h0;
            AccountUtils.m3549e(myWorkActivity, myWorkActivity.getString(R.string.profile_registration_required_popup_upload_title));
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: b */
        public void mo948b() {
            MyWorkActivity myWorkActivity = MyWorkActivity.this;
            int i = MyWorkActivity.f18407h0;
            String string = myWorkActivity.getString(R.string.mail_authorization_submit_illustration);
            MutabilityOwnership.m3746l(string, "getString(jp.pxv.android…tion_submit_illustration)");
            AccountUtils.m3551c(myWorkActivity.m11131K0(), string);
        }

        @Override // p347mm.MailAuthorizationListener
        /* renamed from: c */
        public void mo947c() {
            PixivAnalytics eVar = MyWorkActivity.this.f18757A;
            MutabilityOwnership.m3746l(eVar, "pixivAnalytics");
            eVar.m6527c(3, AnalyticsAction.UPLOAD_SHOW_NOVEL_UPLOAD_VIA_MY_WORK_LIST, null);
            MyWorkActivity.this.startActivityForResult(NovelUploadActivity.C4349a.m4515a(NovelUploadActivity.f19410a0, MyWorkActivity.this, false, null, 4), 1);
        }

        @Override // p347mm.MailAuthorizationListener
        public void failure(Throwable th) {
            MutabilityOwnership.m3745m(th, "e");
            Timber.f23100a.mo3527b(th);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$d */
    /* loaded from: classes2.dex */
    public static final class C4021d extends Lambda implements AbstractC3435a<NovelBackupService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18418a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4021d(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18418a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [am.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final NovelBackupService invoke() {
            return C1124a.m10173s(this.f18418a).f24118a.m920a().m621a(Reflection.m5499a(NovelBackupService.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$e */
    /* loaded from: classes2.dex */
    public static final class C4022e extends Lambda implements AbstractC3435a<PixivSettings> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18419a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4022e(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18419a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ai.b, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final PixivSettings invoke() {
            return C1124a.m10173s(this.f18419a).f24118a.m920a().m621a(Reflection.m5499a(PixivSettings.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$f */
    /* loaded from: classes2.dex */
    public static final class C4023f extends Lambda implements AbstractC3435a<WorkTypeRepository> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18420a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4023f(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18420a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [fl.e, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final WorkTypeRepository invoke() {
            return C1124a.m10173s(this.f18420a).f24118a.m920a().m621a(Reflection.m5499a(WorkTypeRepository.class), null, null);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$g */
    /* loaded from: classes2.dex */
    public static final class C4024g extends Lambda implements AbstractC3435a<ViewModelOwner> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f18421a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4024g(ComponentActivity componentActivity) {
            super(0);
            this.f18421a = componentActivity;
        }

        @Override // p189gn.AbstractC3435a
        public ViewModelOwner invoke() {
            ComponentActivity componentActivity = this.f18421a;
            MutabilityOwnership.m3745m(componentActivity, "storeOwner");
            ViewModelStore viewModelStore = componentActivity.getViewModelStore();
            MutabilityOwnership.m3746l(viewModelStore, "storeOwner.viewModelStore");
            return new ViewModelOwner(viewModelStore, componentActivity);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.activity.MyWorkActivity$h */
    /* loaded from: classes2.dex */
    public static final class C4025h extends Lambda implements AbstractC3435a<MyWorkActionCreator> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f18422a;

        /* renamed from: b */
        public final /* synthetic */ AbstractC3435a f18423b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4025h(ComponentActivity componentActivity, Qualifier aVar, AbstractC3435a aVar2, AbstractC3435a aVar3, AbstractC3435a aVar4) {
            super(0);
            this.f18422a = componentActivity;
            this.f18423b = aVar3;
        }

        /* JADX WARN: Type inference failed for: r0v1, types: [androidx.lifecycle.j0, vj.b] */
        @Override // p189gn.AbstractC3435a
        public MyWorkActionCreator invoke() {
            return progressionUtil.m9685e(this.f18422a, null, null, this.f18423b, Reflection.m5499a(MyWorkActionCreator.class), null);
        }
    }

    public MyWorkActivity() {
        super(R.layout.activity_my_work);
    }

    /* renamed from: e1 */
    public static final Intent m4809e1(Context context) {
        return new Intent(context, MyWorkActivity.class);
    }

    /* renamed from: f1 */
    public final ActivityMyWorkBinding m4808f1() {
        return (ActivityMyWorkBinding) this.f18408b0.getValue();
    }

    /* renamed from: g1 */
    public final NovelBackupService m4807g1() {
        return (NovelBackupService) this.f18411e0.getValue();
    }

    @Override // p270jp.pxv.android.activity.AbstractActivityC4151b, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 109 && i2 == -1) {
            MutabilityOwnership.m3747j(intent);
            if (intent.getBooleanExtra("result_key_should_show_mail_authorization", false)) {
                AccountUtils.m3550d(this, this.f18410d0);
            }
        } else if (i != 1 && i != 2) {
        } else {
            if (i2 == -1 || i2 == 2) {
                ((MyWorkActionCreator) this.f18409c0.getValue()).f29143c.mo2437b(MyWorkAction.C6846a.f29142a);
            }
        }
    }

    @Override // p270jp.pxv.android.activity.AbstractActivityC4151b, p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        MaterialToolbar materialToolbar = m4808f1().f21381e;
        MutabilityOwnership.m3746l(materialToolbar, "binding.toolBar");
        C0536v1.m11537h(this, materialToolbar, R.string.my_works);
        m4808f1().f21380d.setOnSelectSegmentListener(new C7461p(this, 8));
        m4808f1().f21380d.m4467a(getResources().getStringArray(R.array.illust_manga_novel), ((WorkTypeRepository) this.f18413g0.getValue()).m6286c());
    }

    @Override // p014ae.AdActivity, p270jp.pxv.android.activity.BaseActivity, p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        this.f18410d0.m80f();
        super.onDestroy();
    }

    @Subscribe
    public final void onEvent(ShowUploadIllustEvent showUploadIllustEvent) {
        MutabilityOwnership.m3745m(showUploadIllustEvent, "event");
        AccountUtils.m3553a(this.f18410d0, new C4019b(showUploadIllustEvent));
    }

    @Override // p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onStart() {
        super.onStart();
        if (m4807g1().m12056b()) {
            NovelPostParameter c = m4807g1().m12055c();
            if (c == null || !c.m41b()) {
                m4807g1().m12057a();
                return;
            }
            EventPublishDialogFragment.C5840a aVar = EventPublishDialogFragment.f25435a;
            String string = getString(R.string.novel_upload_restore_dialog_message);
            String string2 = getString(R.string.novel_upload_restore_dialog_restore_button);
            MutabilityOwnership.m3746l(string2, "getString(jp.pxv.android…re_dialog_restore_button)");
            EventPublishDialogFragment b = aVar.m2777b(string, string2, getString(R.string.novel_upload_restore_dialog_discard_button), new RestoreNovelBackupFromMyWork(), new DiscardBackupFromMyWork(), getString(R.string.novel_upload_restore_dialog_title), false);
            FragmentManager K0 = m11131K0();
            MutabilityOwnership.m3746l(K0, "supportFragmentManager");
            StringMerger.m2843s(K0, b, "restore_novel_backup");
        }
    }

    @Subscribe
    public final void onEvent(ShowUploadNovelEvent showUploadNovelEvent) {
        MutabilityOwnership.m3745m(showUploadNovelEvent, "event");
        AccountUtils.m3553a(this.f18410d0, new C4020c());
    }

    @Subscribe
    public final void onEvent(RestoreNovelBackupFromMyWork restoreNovelBackupFromMyWork) {
        MutabilityOwnership.m3745m(restoreNovelBackupFromMyWork, "event");
        PixivAnalytics eVar = this.f18757A;
        MutabilityOwnership.m3746l(eVar, "pixivAnalytics");
        eVar.m6527c(3, AnalyticsAction.UPLOAD_NOVEL_RESTORE_VIA_MY_WORK_LIST, null);
        startActivityForResult(NovelUploadActivity.C4349a.m4515a(NovelUploadActivity.f19410a0, this, true, null, 4), 1);
    }

    @Subscribe
    public final void onEvent(DiscardBackupFromMyWork discardBackupFromMyWork) {
        MutabilityOwnership.m3745m(discardBackupFromMyWork, "event");
        PixivAnalytics eVar = this.f18757A;
        MutabilityOwnership.m3746l(eVar, "pixivAnalytics");
        eVar.m6527c(3, AnalyticsAction.UPLOAD_NOVEL_DID_NOT_RESTORE_VIA_MY_WORK_LIST, null);
        m4807g1().m12057a();
    }

    @Subscribe
    public final void onEvent(EditNovelDraftEvent bVar) {
        MutabilityOwnership.m3745m(bVar, "event");
        startActivityForResult(NovelUploadActivity.C4349a.m4515a(NovelUploadActivity.f19410a0, this, false, Long.valueOf(bVar.f28266a), 2), 2);
    }
}
